#include "ulib.h"

bool func1( char *fn1, char *fn2, char *fn3 )
{
	CUTextFile file1( fn1, "r" );
	CUTextFile file2( fn2, "r" );
	CUTextFile file3( fn3, "r" );

	int effect2 = 0;
	int effect3 = 0;

	int now_line = 0;
	while(1)	{
		CUString line1, line2, line3;
		if( file1.ReadLine( line1 ) == false )	break;
		if( file2.ReadLine( line2 ) == false )	break;
		if( file3.ReadLine( line3 ) == false )	break;

		if( line1 != line2 )	effect2++;
		if( line2 != line3 )	effect3++;

		if( line1 != line2 && line2 != line3 && line1 != line3 )	{
			fprintf( stdout, "%d\n", now_line );
			fprintf( stdout, "%s\n", line1.GetStr() );
			fprintf( stdout, "%s\n", line2.GetStr() );
			fprintf( stdout, "%s\n", line3.GetStr() );
			fprintf( stdout, "\n" );
		}


		now_line++;

	}


	fprintf( stderr, "I2 %d chaged\n", effect2 );
	fprintf( stderr, "I3 %d chaged\n", effect3 );

	return true;	
}


int main( int argc, char *argv[] )
{
	if( argc < 2 )	{
		fprintf( stderr, "usage: cmp_line f1 f2 f3\n" );
		return 1;
	}

	if( func1( argv[1], argv[2], argv[3] ) == false )	{
		return 1;
	}

	return 0;
}

